<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="info"></div>
    <script>
        var userinfo = {
            name: '张三',
            age: 18,
            gender: '男'
        }
        var str = '<div>{{name}}</div><div>{{age}}</div>'
            //通过替换的方法来转换replace
        var ret = str.replace('{{name}}', userinfo.name)
        console.log(ret)
        var ret = ret.replace('{{age}}', userinfo.age)
        console.log(ret)
        var div = document.querySelector('.info')
        div.innerHTML = ret
    </script>
</body>

</html>